import typing

# 题目：实现一个函数用来判断字符串是否表示数值，包括整数和小数
# 表示数值的字符串遵循模式 A[.[B]][e|EC]或者.B[e|EC]  上述A，C，均只能以'-' 或者'+'开头


def is_math(s:str):

    if not s or len(s) <1:
        return False

    allow_e = False
    allow_dot = False
    allow_sign = False

    for i in range(len(s)):

        if s[i] == 'e' or s[i] == 'E':
            if allow_e or i == len(s)-1 or i == 0:
                return False
            allow_e = True
        elif s[i] == '.' :
            if allow_dot or allow_e:
                return False
            allow_dot = True

        elif s[i] == '-' or s[i] == '+':
            if not allow_sign and i>0:
                if s[i-1] != 'e' and s[i-1] != 'E':
                    return False
            if allow_sign and (s[i-1] != 'e' and s[i-1] != 'E'):
                return False
            allow_sign =True

        elif s[i] <'0' or s[i]>'9':
            return False

    return True


if __name__ == '__main__':
    a = '123.45e+6'
    b = '.ddasd'
    c = '.23E-8'

    print(is_math(a))
    print(is_math(b))
    print(is_math(c))